﻿<extend name="Public:base" />
<block name="title"><title>我喜欢的项目</title></block>
<block name="header_styles">
    <style type="text/css">
        .search-item {
            width: 233px;
        }

        .main-wrapper .container {
            background-color: #ffffff;
        }

        .form-group {
            margin-bottom: 0px;
        }
    </style>
</block>
<block name="main">
    <div class="tabs-wrapper">
        <div class="section">
            <div class="section-title">
                我收藏的职位 <span class="help-info">这里你可以查看你收藏的职位，以及取消关注不喜欢的职位。</span>
            </div>
            <div class="section-content">
                <div class="search-content">
                    <volist name="favs" id="vo">
                        <div class="search-item">
                            <div class="item-bottom">
                                <if condition="$vo['state'] gt 0">
                                    <div class="item-heading">
                                        <a href="{$vo.pid|genJobURL}">{$vo.name}</a>
                                        <span class="pull-right item-amount">&#165;{$vo.salary}</span>
                                    </div>
                                    <div class="item-row">
                                        <span class="pull-left item-position item-row-col">{$vo.tname}</span>
                                        <a href="javascript:void(0);" class="pull-right tuo-guang <gt name='vo.moneyin' value='0'>active</gt>" style="margin-top:6px;">{$vo.moneyin|toTuoguanDesc}</a>
                                    </div>
                                    <div class="item-row">
                                        <div class="pull-left item-row-col">
                                            招聘人数：<span>{$vo.num}</span>人
                                        </div>
                                        <div class="pull-right item-row-col">
                                            剩余席位：<span>{$vo['num']-$vo['datastate']}</span>人
                                        </div>
                                    </div>
                                    <div class="item-row">
                                        <div class="pull-left item-row-col" style="max-width: 70%;">
                                            <label class="label-creator">创建者：</label>{$vo.creater}
                                        </div>
                                        <!--
                                        <a class="favbtn postnum pull-right item-row-favcol">
                                            <i class="fa fa-heart red"></i>&nbsp;{$vo.fc}
                                        </a>
                                        -->
                                        <a href="javascript:void(0);" class="favbtn postnum pull-right item-row-favcol" data-job="{$vo.id}" data-ftype="2">
                                            <i class="fa fa-heart red"></i>&nbsp;{$vo.fc}
                                        </a>
                                    </div>
                                    <else />
                                    <div class="item-heading">
                                        <a href="{$vo.pid|genJobURL}">{$vo.name}</a>
                                    </div>
                                    <div class="item-row">
                                        <span class="pull-left item-position item-row-col">{$vo.tname}</span>
                                    </div>
                                    <div class="item-row">
                                        <div class="item-row-col item-row-deltip">
                                            <span>该职位已被发布者删除</span>
                                        </div>
                                    </div>
                                    <div class="item-row item-row-col item-row-deltip item-row-delbtn">
                                        <a href="javascript:void(0);" class="favbtn" data-job="{$vo.id}" data-ftype="2"><i class="fa fa-times fa-2x"></i></a>
                                    </div>
                                </if>
                            </div>
                        </div>
                    </volist>
                </div>
                <div class="pagination page-style2">{$page}</div>
                <div style="display: none;">
                    <div id="tooltipcontent1" class="tooltipcontent1">
                        <div style="width:300px;text-align:left;">
                            {$tip}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</block>
<block name="footer_scripts">

    <div style="display: none;">
        <div id="removeConfirm" class="box" style="width:450px;">
            <div class="box-title">
                <a href="javascript:void(0)" class="pull-right" style="color: #ffffff;" onclick="$.fancybox.close();"><i class="fa fa-times"></i></a>
                项目删除
            </div>
            <div class="box-content">
                <p class="text-center">
                    <br />
                    确定要删除您喜欢的项目？
                    <br />
                    <br />
                    （您还可以在项目库中找到它）
                    <br /><br />
                </p>
                <div class="box-buttons">
                    <button class="btn btn-success sure">确定</button>
                    <button class="btn btn-success cancel">取消</button>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        require(["jquery"], function () {
            $(function () {
                $(".favorite-list .item .button-remove").click(function () {
                    var button = $(this);
                    $.fancybox.open("#removeConfirm", { autoSize: true, padding: 0, closeBtn: false });
                    $("#removeConfirm").on("click","button.sure",function () {
                        $.fancybox.close();
                        var itemElement = button.closest(".item");
                        var itemId = itemElement.data("fid"); //favorite ID
                        var tid = itemElement.data("tid");//项目id
                        var url = "{:U('/Project/del_fav/')}";
                        $.post(url, { 'fid': itemId, 'tid': tid }, function (data) {
                            var vdata = eval(data);
                            if (vdata.success == 1) {
                                alert(vdata.msg);
                                itemElement.remove();
                            }
                            else {
                                alert(vdata.msg);
                                return false;
                            }
                        }, 'json');
                    });
                });

                $("#removeConfirm").on("click", "button.cancel", function () { $.fancybox.close(); });
            });
        });
    </script>
    <!--<script type="text/javascript" src="__Public__/js/jobfav.js"></script>-->
    <script type="text/javascript">

       
        require(["modules/jobfav"], function (jobfav) {

            var afterSuccess = function (sender) {
                sender.closest(".search-item").remove();
            };

            var isLogged = parseInt('{$uid!=null?1:0}');
            jobfav.init(isLogged, afterSuccess);
        });

    </script>
</block>
